<template>
  <div class="rightsBox">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/mamger' }"
        >权限管理</el-breadcrumb-item
      >
      <el-breadcrumb-item :to="{ path: '/rights' }"
        >权限列表</el-breadcrumb-item
      >
    </el-breadcrumb>
    <el-card class="box-card">
  
      <!-- 
       "id": 101,
            "authName": "商品管理",
            "level": "0",
            "pid": 0,
            "path": null -->

      <el-table :data="tableData" border style="width: 100%  margin-top:10px">
        <el-table-column type="index" width="50"  align='center'> </el-table-column>

        <el-table-column prop="authName" label="权限名称"   align='center'>
        </el-table-column>
        <el-table-column prop="path" label="路径" align='center'>
        </el-table-column>
        <el-table-column prop="level" label="权限等级" align='center'>

              <template slot-scope="scope">
            <!-- <el-tag   type="scope.row|leve">{{scope.row|leve}}</el-tag> -->
                    <el-tag type="success"  v-if="scope.row.level==0">一级</el-tag>
                    <el-tag type="warning"  v-else-if="scope.row.level==1">二级</el-tag>
                    <el-tag type="danger" v-else>三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { getRights } from "../../api/index";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  created() {
    this.initGetRights();
  },
  methods: {
    async initGetRights() {
      let { data, meta: { status }} = await getRights({ type: "list" });
        if(status!=200) return  this.$message.error('请求失败')
       this.tableData=data
    },
  },
  filters:{
    'leve':function(val,filterParams) {
       switch (val.level) {
         case '0':
             return  '一级'
            case '1':
             return  '二级'
       
         default:
           return '三级'
          
       }
    }
  }
};
</script>

<style>
.box-card {
  width: 1200px;
}
.rightsBox {
  padding-left: 20px;
}

.el-table {
  margin-top: 20px;
}
</style>